package com.zjgsu.nftplatform.client;

import com.zjgsu.nftplatform.pojo.Result;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @author ahy231
 * @date 2022/3/11 15:01
 * @description
 */
@FeignClient("BLOCKCHAIN")
public interface BlockchainClient {

    @RequestMapping(value = "/ipfs/add", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Result addFIle2Ipfs(@ApiParam("文件内容") @RequestBody MultipartFile file);

    @PostMapping("/request")
    Result sendRequest(@ApiParam("参数") @RequestBody Map<String, String> args);

    @GetMapping("/nft/get")
    Result nft(@ApiParam("nft id") @RequestParam String id);

    @PostMapping("/nft/create")
    Result nftCreate(@ApiParam("文件哈希") @RequestParam String fileHash,
                     @ApiParam("用户地址") @RequestParam String address,
                     @ApiParam("密码") @RequestParam String password);

    @PostMapping("/nft/adapt")
    Result nftAdapt(@ApiParam("父母id") @RequestParam String parents,
                    @ApiParam("文件哈希") @RequestParam String fileHash,
                    @ApiParam("用户地址") @RequestParam String address,
                    @ApiParam("密码") @RequestParam String password);

    @PostMapping("/account/new")
    Result accountNew(@ApiParam("密码") @RequestParam String password);

    @GetMapping("/nft/idByFileHash")
    Result getIdByFileHash(@ApiParam("文件哈希") @RequestParam String fileHash);

    @GetMapping("/purchase/isSeller")
    Result isSeller(@ApiParam("cid") @RequestParam String cid,
                    @ApiParam("用户地址") @RequestParam String uaddr);

    @PostMapping("/purchase/publication/create")
    Result createPublication(@ApiParam("cid") @RequestParam String cid,
                             @ApiParam("出版权期限（天）") @RequestParam String dayTime,
                             @ApiParam("用户地址") @RequestParam String address,
                             @ApiParam("密码") @RequestParam String password);

    @GetMapping("/purchase/publication/search")
    Result searchPublication(@ApiParam("nft id") @RequestParam String nftId);

    @PostMapping("/set/stake")
    Result setStake(@ApiParam("pid") @RequestParam String pid,
                    @ApiParam("stake") @RequestParam String stake,
                    @ApiParam("用户地址") @RequestParam String address,
                    @ApiParam("密码") @RequestParam String password);

    @PostMapping("/set/price")
    Result setPrice(@ApiParam("pid") @RequestParam String pid,
                    @ApiParam("price") @RequestParam String price,
                    @ApiParam("用户地址") @RequestParam String address,
                    @ApiParam("密码") @RequestParam String password);

    @GetMapping("/publication/{pid}")
    Result getPublicationById(@ApiParam("pid") @PathVariable String pid);

    @GetMapping("/stake/{pid}/{uaddr}")
    Result getStakeById(@ApiParam("pid") @PathVariable String pid,
                        @ApiParam("uaddr") @PathVariable String uaddr);

    @GetMapping("/price/{pid}/{uaddr}")
    Result getPriceById(@ApiParam("pid") @PathVariable String pid,
                        @ApiParam("uaddr") @PathVariable String uaddr);

    @PostMapping("/publication/agree")
    Result agreePublication(@ApiParam("id") @RequestParam String id,
                            @ApiParam("price") @RequestParam String price,
                            @ApiParam("用户地址") @RequestParam String address,
                            @ApiParam("密码") @RequestParam String password);
}
